package com.wm.blog_admin.controller.base;

import com.wm.blog_common.constatnt.CommonConstant;
import com.wm.blog_common.context.AdminBaseContextHandler;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

/***
 * @ClassName: AdminBaseController
 * @Description: admin后台controller基类
 * @Author: 半卷流年
 * @Create_time: 22:46 2020-3-24
 */
@Deprecated
public class AdminBaseController {

    /**
     * 当前登录人的id
     * @param request
     * @return
     */
    @Deprecated
    public Long currentAdminId(HttpServletRequest request){
        String header = request.getHeader(CommonConstant.ADMIN);
        return StringUtils.isNotEmpty(header) ? Long.parseLong(header) : -1L;
    }


    public Long currentAdminId(){
        return AdminBaseContextHandler.getAdminUserId();
    }

    public String currentUserName(){
        return AdminBaseContextHandler.getAdminUserName();
    }


    /**
     * 当前的请求头
     * @param request
     * @return
     */
    public String currentAuthorization(HttpServletRequest request){
       return request.getHeader(CommonConstant.AMIND_Authorization);
    }
}
